package main

import (
	"encoding/json"
	"log"
	"os"
	"strconv"
	"time"
)

type Item struct {
	Id    int
	Name  string
	Price float64
	time  time.Time
}

func NewItem(id int, name string, price float64, time time.Time) *Item {
	return &Item{Id: id, Name: name, Price: price, time: time}
}

func FlushList(t time.Time, itemList []*Item) {
	itemName := strconv.FormatInt(t.Unix(), 10)
	listDir := GetListDir(itemName)
	bc.Log("抓取保存路径:" + listDir)
	marshal, err := json.Marshal(itemList)

	if err != nil {
		log.Println("flush fail :path", itemName)
	}
	os.WriteFile(listDir, marshal, 0644)
}
